from utils import xprimes
from itertools import combinations


def is_seq(l):
    return l[1] - l[0] == l[2] -l[1]


buckets = {}

for p in xprimes(10000):
    if p < 1000:
        continue
    key = ''.join(sorted(str(p)))
    if key in buckets:
        buckets[key].append(p)
    else:
        buckets[key] = [p]

for key in buckets.keys():
    nums = buckets[key]
    if len(nums) < 3:
        continue
    for l in combinations(nums, 3):
        if is_seq(l):
            print l

    

